package JMH.day01;

import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;

import java.util.concurrent.TimeUnit;

@Warmup(iterations = 1)
@Fork(1)
@Measurement(iterations = 5)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Benchmark)
public class JMHExample04 {

    @Setup(Level.Invocation)
    public void setUp() {
        System.out.println("Iteration");
    }

    @Benchmark
    public void say() {
        System.out.println("say");
    }

    public static void main(String[] args) throws RunnerException {
        // 初始化setUp模式的级别
        Options options = new OptionsBuilder().include(JMHExample04.class.getSimpleName())
                .build();
        new Runner(options).run();
    }

}
